function [w,p_reservation,H_p_reservation] = w_match_fun(v_old,p,pdf,g_I,C,Np,N,cdf);

w = zeros(Np,N);
p_reservation = zeros(Np,N);
H_p_reservation = zeros(Np,N);

mean_mat = zeros(Np,N);

    for l=1:N
        
       
            MatVml=max(repmat(v_old(:,l)-C(:,l),1,Np)-repmat(transpose(v_old(:,l)),Np,1),0);
            mean_mat(:,l) = transpose(MatVml)*transpose(pdf);

            for i = 1:Np
                temp = find(MatVml(:,i)==0);
                index = Np - size(temp,1);
                if index>0
                    p_reservation(i,l) = (p(index));
                    H_p_reservation(i,l) = (cdf(index));
                end
            end
           
            clear vars temp index;
        
    end
    
w= mean_mat * transpose(g_I);

end

